#ifndef __STMFLASH_H__
#define __STMFLASH_H__

#include <stdint.h>

#define STM32_FLASH_BASE 0x08000000 	//FLASH BASE ADDR
#define FLASH_WAITETIME  50000          //FLASH TIMEOUT


//FLASH SECTOR
#define ADDR_FLASH_SECTOR_0     ((uint32_t)0x08000000) 	// 	16 Kbytes
#define ADDR_FLASH_SECTOR_1     ((uint32_t)0x08004000) 	// 	16 Kbytes
#define ADDR_FLASH_SECTOR_2     ((uint32_t)0x08008000) 	// 	16 Kbytes
#define ADDR_FLASH_SECTOR_3     ((uint32_t)0x0800C000) 	// 	16 Kbytes
#define ADDR_FLASH_SECTOR_4     ((uint32_t)0x08010000) 	// 	64 Kbytes
#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08020000) 	// 	128 Kbytes
#define ADDR_FLASH_SECTOR_6     ((uint32_t)0x08040000) 	// 	128 Kbytes
#define ADDR_FLASH_SECTOR_7     ((uint32_t)0x08060000) 	// 	128 Kbytes
#define ADDR_FLASH_SECTOR_8     ((uint32_t)0x08080000) 	// 	128 Kbytes
#define ADDR_FLASH_SECTOR_9     ((uint32_t)0x080A0000) 	// 	128 Kbytes
#define ADDR_FLASH_SECTOR_10    ((uint32_t)0x080C0000) 	//	128 Kbytes
#define ADDR_FLASH_SECTOR_11    ((uint32_t)0x080E0000) 	//	128 Kbytes

extern void STMFLASH_Init(void);
extern uint32_t STMFLASH_ReadWord(uint32_t faddr);
extern uint8_t STMFLASH_GetFlashSector(uint32_t addr);
extern void STMFLASH_Write(uint32_t WriteAddr,uint32_t *pBuffer,uint32_t NumToWrite);
extern void STMFLASH_Read(uint32_t ReadAddr,uint32_t *pBuffer,uint32_t NumToRead);

#endif
